/**
 * Copyright &copy; 2016-2017 <a href="http://git.oschina.net/whoamien/backend_management">Backend Management</a> All rights reserved.
 */
package com.xw.app.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xw.app.dao.AcctRoleDAO;
import com.xw.app.model.AcctRole;
import com.xw.app.service.AcctRoleService;
import com.xw.framework.base.service.BaseServiceImpl;

/**
 * The Class AcctRoleServiceImpl.
 *
 * @author Xi Wei
 */
@Service
@Transactional
public class AcctRoleServiceImpl extends BaseServiceImpl<AcctRole, Long> implements AcctRoleService {

	@Autowired
	private AcctRoleDAO acctRoleDAO;
	
	/* (non-Javadoc)
	 * @see com.xw.app.service.AcctRoleService#checkRoleExist(java.lang.String, java.lang.Long)
	 */
	@Override
	public boolean checkRoleExist(String roleCode,Long id) {
		
		List<AcctRole> list = null;
		if(id == null){
			list = acctRoleDAO.findByRoleCode(roleCode);
		}else{
			list = acctRoleDAO.findByRoleCodeAndIdNot(roleCode, id);
		}
		if(list == null || list.isEmpty()){
			return false;
		}else
		{
			return true;
		}
	}

}
